package com.example.practical_training_projects.mapper;
import com.example.practical_training_projects.entity.test2;
import com.example.practical_training_projects.vo.votest2class;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface test2Mapper {
    @Select("select * from test2")
    List<test2> getAlltest2();

    @Delete("delete from test2 where t2_uid=#{t2_uid}")
    Integer deleteTest2(Integer t2_uid);
    @Insert("insert into test2 (t2_context,t2_answer1,t2_answer2,ts_uid)"+
            " values (#{t2_context},#{t2_answer1},#{t2_answer2},#{ts_uid})")
    Integer insertTest2(test2 t2_uid);

    @Select("select * from test2 where t2_uid = #{t2_uid}")
    test2 findTest2uid(Integer t2_uid);

    @Update("update test2 set t2_context=#{t2_context},t2_answer1=#{t2_answer1},t2_answer2=#{t2_answer2},ts_uid=#{ts_uid} where t2_uid = #{t2_uid}")
    Integer updateTest2(test2 test2);

    @Select("select *from test2 where t2_context like '%${name}%'")
    List<test2>  getContest2(String t2_context);

//    @Select("select *from test2 where t_class like '%${name}%'")
//    List<test2>  getClass(String t_class);

    @Select("select t2.*,ts.ts_class from test2 t2 join testselect ts on t2.ts_uid = ts.ts_uid  order by t2_uid desc\n")
    List<votest2class> findAlltest2Andclass();

    @Select("select t2.*,ts.ts_class from test2 t2 join testselect ts on t2.ts_uid = ts.ts_uid where t2.t2_context like '%${name}%' ")
    List<votest2class> findtest2Bycontext(String t2_context);
    @Select("select t2.*,ts.ts_class from test2 t2 join testselect ts on t2.ts_uid = ts.ts_uid where t2.t2_context like '%${t2_context}%'\n" +
            " and ts.ts_uid like '%${ts_uid}%'")
    List<votest2class> findtest2BycontextAndclassuid(@Param("ts_uid") Integer ts_uid,@Param("t2_context") String t2_context);}